<style>
    .messages .item {
        padding: 15px 0;
        border-bottom: 1px dashed var(--max-grey-font-color);

    }

    .messages .item.bold {
        font-weight: 600;
    }

    .messages .item .title {
        font-size: 16px;
        color: (--font-color);
    }

    .messages .item .time {
        color: var(--grey-font-color);
    }
</style>
<div class=" rc-pannel rc-pagepadding layui-form">
    <div class="rc-pannel-header">
        <div class="rc-flex rc-flex-between rc-flex-item-center" style="margin-bottom:5px">

            <div>
                <input type="checkbox" name="AAA" lay-filter="checkAll" title="系统消息">

            </div>
            <div>

                <button type="button" class="layui-btn layui-btn-sm" id="setAllRead">
                    <i class="layui-icon layui-icon-fonts-clear"></i>
                    全部标记已读
                </button>
                <button type="button" class="layui-btn layui-btn-sm layui-border-blue" id="delmessage">
                    <i class="layui-icon layui-icon-reduce-circle"></i>
                    删除
                </button>

            </div>
        </div>
    </div>
    <div class="rc-pannel-body">



        <div class="messages">

            <?php
            foreach ($messages as $key => $message) {
            ?>
                <div class="item rc-flex rc-flex-between rc-flex-item-center <?php echo $message->isread == 0 ? 'bold' : '' ?>">
                    <div class="title">
                        <input type="checkbox" class="item_checkbox" value="<?php echo $message->id ?>" autocomplete="off" />
                        <a <?php echo $message->link ? 'target="_blank"' : '' ?> href="<?php echo $message->link ? $message->link : 'javascript:void(0)' ?>">
                            <?php echo $message->content ?>
                        </a>


                    </div>
                    <div class="time">
                        <?php echo $message->sendtime ?>
                    </div>

                </div>


            <?php
            }
            ?>


        </div>


    </div>

    <div class="rc-pannel-footer">
        <div id="pagebar">
            <?php echo paginator($messages->total(), 20); ?>

        </div>
    </div>
</div>



<script>
    layui.use(function() {
        var form = layui.form;
        $('#delmessage').click(function() {
            var ids = getAllChkIds();
            if (ids == '') {
                toastr_error('请选择要删除的消息');
                return;
            }

            $.ajax({
                url: '/uc/UserMessage/delete', //请求路径
                type: "POST", //请求方式
                data: {
                    ids: ids,
                },
                success: function(data) {
                    if (data.code == 0) {
                        window.location.reload();

                    } else {
                        toastr_error(data.message);
                    }
                },
                error: function() {

                },

            });
        });


        $('#setAllRead').click(function() {
            $.ajax({
                url: '/uc/UserMessage/setAllRead', //请求路径
                type: "POST", //请求方式
                success: function(data) {
                    if (data.code == 0) {
                        toastr_success('标记已读成功', function() {
                            window.location.reload();
                        });



                    } else {
                        toastr_error(data.message);
                    }
                },
                error: function() {

                },

            });
        })

    });
</script>